﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Module;
using BLL.Common;
using BLL;

public partial class User_ShowUserInfo : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            string userProIdStr = Request.QueryString["UID"];
            if (!string.IsNullOrWhiteSpace(userProIdStr))
            {
                string decryUserProIdStr = Contexts.GetDecrypt(userProIdStr);
                try
                {
                    decryUserProIdStr = Contexts.GetDecrypt(userProIdStr);
                }
                catch (Exception ex)
                {
                }
                if (string.IsNullOrWhiteSpace(decryUserProIdStr))
                {
                    decryUserProIdStr = userProIdStr;
                }
                this.uid.Value = userProIdStr;
                long userProId = Convert.ToInt64(decryUserProIdStr);
                UserProfileInfo userInfo = BLL.BUserProfile.getInstance().GetUserProfileInfo(userProId);
                UserPassportInfo userPassportInfo = BLL.BUserPassport.getInstance().GetUserPassportInfo(userProId);
                if (userInfo != null)
                {
                    // 设置各个字段值
                    this.label_userType.Text = CommonUtils.GetRoleValue(Convert.ToString(userInfo.UserType));
                    this.label_userName.Text = userPassportInfo.UserName;
                    this.label_reanName.Text = userInfo.RealName;
                    this.label_nickName.Text = userInfo.NickName;
                    this.label_IdNum.Text = userInfo.IDCardNum;
                    this.label_email.Text = userInfo.Email;
                    this.label_PhoneNumber.Text = userInfo.Mobile;
                    this.label_gender.Text = CommonUtils.GetGenderValue(Convert.ToString(userInfo.Gender));
                    this.label_birthday.Text = userInfo.Birthday.ToString("yyyy年MM月dd日");
                    this.label_Education.Text = CommonUtils.GetEducationValue(Convert.ToString(userInfo.Education));
                    if(userInfo.ProvinceId>0)
                    {
                        List<AreaInfo> areas = BArea.getInstance().GetALLArea();
                        AreaInfo p = areas.Find(delegate(AreaInfo o)
                        {
                            if (o.AreaCode == userInfo.ProvinceId)
                                return true;
                            else
                                return false;
                        });
                        if (p != null && p.AreaCode > 0)
                        {
                            this.label_province.Text = p.AreaName;
                        }
                        if (userInfo.CityId > 0)
                        {
                            p = areas.Find(delegate(AreaInfo o)
                            {
                                if (o.AreaCode == userInfo.CityId)
                                    return true;
                                else
                                    return false;
                            });
                            if (p != null && p.AreaCode > 0)
                            {
                                this.label_city.Text = p.AreaName;
                            }
                        }          

                    }
                    this.label_address.Text = userInfo.Adress;
                    this.label_PersonalIncome.Text = CommonUtils.GetInComeValue(Convert.ToString(userInfo.PersonalInCome));
                    this.label_FamilyIncome.Text = CommonUtils.GetInComeValue(Convert.ToString(userInfo.FamilyInCome));
                }
            }
        }
    }
    protected void Btn_OK_Click(object sender, EventArgs e)
    {
        Response.Redirect(string.Format("UserAdd.aspx?UID={0}",this.uid.Value));
    }
}